const Koa = require('koa');
// 路由配置
const route = require('koa-route');
const fs = require('fs')
// 允许静态资源被访问 直接在路径后面跟着资源名字即可
const static = require('koa-static')
const staticPath = './asset'
const path = require('path')

const app = new Koa();

// 重定向
const redirect = ctx => {
  ctx.response.redirect('/');
};

const main = ctx => {
  ctx.response.body = '呵呵'
};

// 使用中间件
app.use(static(
  path.join( __dirname,  staticPath)
))
app.use(route.get('/', main));
app.use(route.get('/temp', redirect));

app.listen(80,()=>{
  console.log('server start')
});
